package com.zyt.service.impl;

import com.zyt.dao.JarMapper;
import com.zyt.pojo.Jar;
import com.zyt.service.JarService;
import com.zyt.util.MyBitisUtil;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class JarServiceImpl implements JarService {
    @Override
    public void insert(Jar jar) {
        SqlSession sqlSession= null;
        try {
            sqlSession= MyBitisUtil.getSession();
            JarMapper studentMapper =sqlSession.getMapper(JarMapper.class);
            studentMapper.insert(jar);
            sqlSession.commit();
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            MyBitisUtil.closeSession(sqlSession);
        }
    }

    @Override
    public List<Jar> selectAll() {
        SqlSession sqlSession= null;
        List<Jar> jarList=null;
        try {
            sqlSession= MyBitisUtil.getSession();
            JarMapper studentMapper =sqlSession.getMapper(JarMapper.class);
            jarList= studentMapper.selectAll();
        }catch (Exception e){
            e.printStackTrace();
        }finally {
            MyBitisUtil.closeSession(sqlSession);
        }
        return jarList;
    }
}
